﻿@{
    ViewData["Title"] = "View Without ID";
}

@section ContentHeader {
    <h1>@ViewData["Title"]<small></small></h1>
}

<div class="alert alert-info alert-dismissable">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
    <p>One of the frequently asked questions about Serenity is how to work views, and especially with ones without an ID column.</p>
    <p>Actually this is a requirement of SlickGrid, as it needs a unique ID for items.</p>
    <p>It could be possible to use an expression field (doesn't have to be in view) by concatting view fields to get a composite ID.</p>
    <p>Anyway in this sample we are using a view from Northwind (Sales By Category) that doesn't have an ID, and we are not using a composite key.</p>
    <p>See @Html.AppSourceFile("ViewWithoutIDGrid.ts") for how to set a fake autoincrementing ID client side by intercepting OnViewProcessData method.</p>
    
    <p style="text-align: right;"><b>Source Files:</b> @Html.AppSourceFile("Index.cshtml"), @Html.AppSourceFile("ViewWithoutIDGrid.ts")</p>
</div>

<div id="GridDiv"></div>

<script type="text/javascript">
    jQuery(function () {
        new Serene.BasicSamples.ViewWithoutIDGrid($('#GridDiv'), {}).init();

        Q.initFullHeightGridPage($('#GridDiv'));
    });
</script>